package com.xjrsoft.module.workflow.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.module.workflow.entity.XjrNwfScheme;
import com.xjrsoft.module.workflow.entity.XjrNwfSchemeinfo;
import com.xjrsoft.module.workflow.mapper.NwfSchemeMapper;
import com.xjrsoft.module.workflow.service.IXjrNwfSchemeInfoService;
import com.xjrsoft.module.workflow.service.IXjrNwfSchemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class XjrNwfSchemServiceImpl extends ServiceImpl<NwfSchemeMapper, XjrNwfScheme> implements IXjrNwfSchemeService {

	@Autowired
	private IXjrNwfSchemeInfoService xjrNwfSchemeInfoService;

	@Override
	public XjrNwfScheme getBySchemeInfoId(String schemeInfoId) {
		QueryWrapper<XjrNwfScheme> queryWrapper = new QueryWrapper();
		queryWrapper.eq("F_SchemeInfoId", schemeInfoId);

		return this.getOne(queryWrapper, false);
	}

	/**
	 * @Author:湘北智造-框架开发组
	 * @Date:2020/10/20
	 * @Param:[modelId]
	 * @return:java.lang.String
	 * @Description:从nwfscheme表中查json
	 */
	public JSONObject getSchemeJsonByInfoId(String nwfSchemeInfoId) {
		XjrNwfSchemeinfo xjrNwfSchemeinfo = xjrNwfSchemeInfoService.getById(nwfSchemeInfoId);
		if (xjrNwfSchemeinfo != null) {
			String schemeId = xjrNwfSchemeinfo.getSchemeId();
			XjrNwfScheme xjrNwfScheme = this.getById(schemeId);
			if (xjrNwfScheme != null) {
				return JSON.parseObject(xjrNwfScheme.getFjson());
			}
		}
		return null;
	}

}
